﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Koonsoft.HYCRM.DAL;
using Koonsoft.HYCRM.Model;

namespace Koonsoft.HYCRM.BLL
{
    public class AuditorsBLL
    {
        /// <summary>
        /// 新增银行对账单
        /// </summary>
        public bool CreateCompanyBank(List<CreateBankEntity> list, out string msg)
        {
            return new AuditorsDAL().CreateCompanyBank(list, out msg);
        }

        /// <summary>
        /// 新增银行对账单
        /// </summary>
        public bool CreateCompanyBank(CreateBankEntity entity, out string msg)
        {
            return new AuditorsDAL().CreateCompanyBank(entity, out msg);
        }

        /// <summary>
        /// 新增销售明细
        /// </summary>
        public bool CreateSales(List<CreateSalesEntity> list, out string msg)
        {
            return new AuditorsDAL().CreateCompanySales(list, out msg);
            ;
        }

        /// <summary>
        /// 新增购货明细
        /// </summary>
        public bool CreatePurchase(List<CreatePurchaseEntity> list, out string msg)
        {
            return new AuditorsDAL().CreateCompanyPurchase(list, out msg);
        }


        /// <summary>
        /// 获取银行对账单
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public DataTable GetCompanyBank(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetCompanyBank(CompanyID, orderid);
        }

        /// <summary>
        /// 获取银行对账单
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public DataTable GetCompanyBank(string CompanyID, string orderid, string Currency)
        {
            return new AuditorsDAL().GetCompanyBank(CompanyID, orderid, Currency);
        }

        /// <summary>
        /// 获取银行对账单 其他
        /// currency not in (1,98,99) 
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public DataTable GetCompanyBankOther(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetCompanyBankOther(CompanyID, orderid);
        }

        /// <summary>
        /// 获取银行结余
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public double GetCashAtBank(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetCashAtBank(CompanyID, orderid);
        }

        /// <summary>
        /// 获取购货凭证
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public DataTable GetCompanyPurchase(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetCompanyPurchase(CompanyID, orderid);
        }

        /// <summary>
        /// 获取销货凭证
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public DataTable GetCompanySales(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetCompanySales(CompanyID, orderid);
        }

        /// <summary>
        /// 获取汇率
        /// </summary>
        /// <returns></returns>
        public List<ExchangeRateEntity> GetExchangeRate()
        {
            return new AuditorsDAL().GetExchangeRate();
        }

        /// <summary>
        /// 获取汇率
        /// </summary>
        /// <returns></returns>
        public ExchangeRateEntity GetExchangeRate(string orderid, string source)
        {
            return new AuditorsDAL().GetExchangeRate(orderid, source);
        }


        /// <summary>
        /// 获取币种
        /// </summary>
        /// <returns></returns>
        public List<CurrencyEntity> GetExchangeCurrency()
        {
            return new AuditorsDAL().GetExchangeCurrency();
        }

        /// <summary>
        /// 获取类型提供者
        /// </summary>
        /// <returns></returns>
        public List<TypeProviderEntity> GetTypeProvider()
        {
            return new AuditorsDAL().GetTypeProvider();
        }

        /// <summary>
        /// 新增购货明细类型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="TypeProviderID"></param>
        public void CreateDetailTypes(string name, string englishName, string TypeProviderID, string kinds)
        {
            new AuditorsDAL().CreateDetailTypes(name, englishName, TypeProviderID, kinds);
        }

        /// <summary>
        /// 获取类型
        /// </summary>
        /// <returns></returns>
        public List<DetailTypesEntity> GetDetailTypes()
        {
            return new AuditorsDAL().GetDetailTypes();
        }


        /// <summary>
        /// 获取明细
        /// </summary>
        /// <returns></returns>
        public List<CompanyDetailEntity> GetCompanyDetail(string companyid, string orderid)
        {
            return new AuditorsDAL().GetCompanyDetail(companyid, orderid);
        }

        ///// <summary>
        ///// 获取明细
        ///// </summary>
        ///// <returns></returns>
        //public List<CompanyDetail_NewEntity> GetCompanyDetail_New(string companyid, string orderid)
        //{
        //    return new AuditorsDAL().GetCompanyDetail_New(companyid, orderid);
        //}

        /// <summary>
        /// 新增明细
        /// </summary>
        public bool CreateCompanyDetail(string companyId, string orderId, List<CompanyDetailEntity> list, out string msg)
        {
            new AuditorsDAL().DeleteCompanyDetail(companyId, orderId);
            return new AuditorsDAL().CreateCompanyDetail(list, out msg);
        }

        /// <summary>
        /// 明细报表
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public DataTable GetCompanyDetailTable(string companyId, string orderId)
        {
            return new AuditorsDAL().GetCompanyDetailTable(companyId, orderId);
        }

        /// <summary>
        /// 盈利亏损
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public double GetCompanyProfitLosses(string companyId, string orderId)
        {
            return new AuditorsDAL().GetCompanyProfitLosses(companyId, orderId);
        }

        /// <summary>
        /// 计算购货凭证
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public int CalculationCompanyPurchase(string CompanyID, string orderid)
        {
            return new AuditorsDAL().CalculationCompanyPurchase(CompanyID, orderid);
        }

        /// <summary>
        /// 计算销货凭证
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public int CalculationCompanySales(string CompanyID, string orderid)
        {
            return new AuditorsDAL().CalculationCompanySales(CompanyID, orderid);
        }


        /// <summary>
        /// 获取利得税
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public double GetProfitTax(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetProfitTax(CompanyID, orderid);
        }

        /// <summary>
        /// 新增利得税
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="date"></param>
        /// <param name="value"></param>
        public void InsertProfitTax(string CompanyID, string OrderID, double value)
        {
            new AuditorsDAL().InsertProfitTax(CompanyID, OrderID, value);
        }


        /// <summary>
        /// 计算利得税
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public double CalculationProfitTax(string CompanyID, string orderid)
        {
            return new AuditorsDAL().CalculationProfitTax(CompanyID, orderid);
        }

        /// <summary>
        /// 获取利润
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public double GetProfit(string CompanyID, string OrderID)
        {
            return new AuditorsDAL().GetProfit(CompanyID, OrderID);
        }

        /// <summary>
        /// 获取管理费
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public double GetBankCharge(string CompanyID, string OrderID)
        {
            return new AuditorsDAL().GetBankCharge(CompanyID, OrderID);
        }

        /// <summary>
        /// 获取利息
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public double GetBankInterestIncome(string CompanyID, string OrderID)
        {
            return new AuditorsDAL().GetBankInterestIncome(CompanyID, OrderID);
        }


        /// <summary>
        /// 获取公司评价
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public string GetEvaluation(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetEvaluation(CompanyID, orderid);
        }

        /// <summary>
        /// 新增公司评价
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="date"></param>
        /// <param name="value"></param>
        public void InsertEvaluation(string CompanyID, string date, string value)
        {
            new AuditorsDAL().InsertEvaluation(CompanyID, date, value);
        }

        /// <summary>
        /// 获取收入
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public int GetRevenue(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetRevenue(CompanyID, orderid);
        }

        /// <summary>
        /// 获取成本
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public int GetCost(string CompanyID, string orderid)
        {
            return new AuditorsDAL().GetCost(CompanyID, orderid);
        }

        /// <summary>
        /// 删除银行对账单
        /// </summary>
        public void DeleteCompanyBank(string id)
        {
            new AuditorsDAL().DeleteCompanyBank(id);
        }

        /// <summary>
        ///
        /// </summary>
        public void DeleteCompanyPurchase(string id)
        {
            new AuditorsDAL().DeleteCompanyPurchase(id);
        }

        /// <summary>
        ///
        /// </summary>
        public void DeleteCompanySales(string id)
        {
            new AuditorsDAL().DeleteCompanySales(id);
        }


        /// <summary>
        /// 获取上期結餘列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetCompanyBankMantissa(string CompanyID, string orderID)
        {
            return new AuditorsDAL().GetCompanyBankMantissa(CompanyID, orderID);
        }

        /// <summary>
        /// 获取指定币种結餘
        /// </summary>
        /// <returns></returns>
        public double GetCompanyBankMantissa(string CompanyID, string orderID, string Currency)
        {
            return new AuditorsDAL().GetCompanyBankMantissa(CompanyID, orderID, Currency);
        }

        /// <summary>
        /// 新增或修改上期银行結餘
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderID"></param>
        /// <param name="Currency"></param>
        /// <param name="Amount"></param>
        public void AddOrUpdateCompanyBankMantissa(string CompanyID, string orderID, string Currency, double Amount)
        {
            new AuditorsDAL().DeleeteBankMantissa(CompanyID, orderID, Currency);
            new AuditorsDAL().AddBankMantissa(CompanyID, orderID, Currency, Amount);
        }

        /// <summary>
        /// 获取最后银行結餘
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderID"></param>
        /// <param name="Currency"></param>
        /// <returns></returns>
        public double GetLastCompanyBankMantissa(string CompanyID, string orderID, string Currency)
        {
            return new AuditorsDAL().GetLastCompanyBankMantissa(CompanyID, orderID, Currency);
        }



        /// <summary>
        /// 获取银行销货、购货金额
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderID"></param>
        /// <param name="explain">0:销货  1:购货</param>
        /// <returns></returns>
        public List<ContrastAmount> GetBankSalesAmount(string CompanyID, string orderID, string explain)
        {
            return new AuditorsDAL().GetBankSalesAmount(CompanyID, orderID, explain);
        }


        /// <summary>
        /// 获取销货金额
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderID"></param>
        /// <returns></returns>
        public List<ContrastAmount> GetSalesAmount(string CompanyID, string orderID)
        {
            return new AuditorsDAL().GetSalesAmount(CompanyID, orderID);
        }

        /// <summary>
        /// 获取购货金额
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderID"></param>
        /// <returns></returns>
        public List<ContrastAmount> GetPurchaseAmount(string CompanyID, string orderID)
        {
            return new AuditorsDAL().GetPurchaseAmount(CompanyID, orderID);
        }

        /// <summary>
        /// 获取银行流水报表
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="orderID"></param>
        /// <param name="Currency"></param>
        /// <returns></returns>
        public List<BankTableDetailEmtity> GetBankTableDetail(string CompanyID, string orderID, string Currency)
        {
            return new AuditorsDAL().GetBankTableDetail(CompanyID, orderID, Currency);
        }


        public void CreateAccountantDelegate(string orderID, int empolyeeID)
        {
            new AuditorsDAL().CreateAccountantDelegate(orderID, empolyeeID);
        }
    }
}
